package com.ww.cheappliers.receive;

import java.util.Observable;

import org.apache.log4j.Logger;

import com.ww.cheappliers.Message;
import com.ww.cheappliers.consumer.MessageConsumer;

/**
 * 接受消息的基类 例如 从邮件接受消息 例如 从socek接受消息等等
 * @author tengHy
 *
 */
public abstract class AbstractMessageReaper extends Observable implements MessageReaper {
	private final Logger log = Logger.getLogger(this.getClass());
	public void start(){
		while(true){
			log.info("Check Message...");
			Message[] msgs = extractMessage();
			if(msgs == null || msgs.length <= 0)
				continue;
			log.info("Got Message...");
			this.setChanged();
			this.notifyObservers(msgs);
		}
	}

	public void addConsumer(MessageConsumer c) {
		addObserver(c);
	}

}
